package com.example.order.controller;


import com.example.feign.bo.Person01BO;
import com.example.feign.clients.UserClientFeignApi;
import com.example.order.config.PropertiesConfig;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.reactive.context.StandardReactiveWebEnvironment;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.env.Environment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Locale;

/**
 * 三种获取配置以及热更新
 * Environment Value ConfigurationProperties
 */
@RestController
@RequestMapping(value = "/order")
@RefreshScope//@Value热更新
public class UserController {
    @Autowired
    private Environment environment;

    @Value("${logging.pattern.dateformat}")
    private String dateformat;

    @Autowired
    private PropertiesConfig config;

    @ResponseBody
    @RequestMapping(value = "/getEnv1", method = RequestMethod.GET)
    public String getEnv1() {
        StandardEnvironment standardEnvironment = (StandardEnvironment) environment;
        String property = environment.getProperty("logging.pattern.dateformat");
        System.out.println(property);
        return property;
    }

    @ResponseBody
    @RequestMapping(value = "/getEnv2", method = RequestMethod.GET)
    public String getEnv2() {
        System.out.println(dateformat);
        return dateformat;
    }

    @ResponseBody
    @RequestMapping(value = "/getEnv3", method = RequestMethod.GET)
    public String getEnv3() {
        System.out.println(config.getDateformat());
        return config.getDateformat();
    }

}

